package com.xukai.springboot.quartzTask;

import com.xukai.springboot.service.statistics.DataCaptureService;
import com.xukai.springboot.service.statistics.DataSourceService;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

@DisallowConcurrentExecution
public class UpdateStatisTask implements Job {

    @Autowired
    DataSourceService dataSourceService;

    /**
     * 数据抓取服务
     */
    @Autowired
    private DataCaptureService dataCaptureService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            JobKey key = jobExecutionContext.getJobDetail().getKey();
            System.out.println("任务开始 " + key.getName());
            dataCaptureService.UpdateStatisDataByID(Integer.valueOf(key.getName()));
            System.out.println("任务结束" + key.getName());
        } catch (Exception e) {
        }
    }
}
